<?php

namespace app\api\controller;

use app\common\controller\Api;
use EasyWeChat\Factory;
use app\api\controller\My;
use think\Db;

/**
 * 首页接口
 */
class Xcx0702 extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 首页
     *
     */
    public function index()
    {
        $this->success('请求成功');
    }
    public function getPhonetype()
    {
        $ua = $this->request->request('ua');
        return $this->success('', my::getPhonetype($ua));
    }

    /**
     * 小程序手机号获取
     */
    public  function xcxlogin()
    {
        $code = $this->request->request('code');
        $rst =  Wechat::xcxlogin1($code);
        return $this->success('', $rst);
    }
    public function addContent()
    {
        $sex = $this->request->request('sex');
        $age = $this->request->request('age');
        $area = $this->request->request('area');
        $hobby = $this->request->request('hobby');
        $openid = $this->request->request('openid');
        $new = [
            'sex' => $sex,
            'age' => $age,
            'area' => $area,
            'hobby' => $hobby,
            'openid' => $openid,
            'createtime' => time()
        ];
        $res = Db::table('fa_xcx0702_list')->insert($new);
        return $this->success('提交成功');
        //fa_xcx0702_list
    }
    public function getInfo()
    {
        $data = Db::table('fa_admin')->field(['xcx0702_text', 'xcx0702_hf', 'xcx0702_skm', 'xcx0702_bjs', 'xcx0702_3', 'xcx0702_4'])->where('id', 1)->find();
        return $this->success('', $data);
    }
}
